package cn.iocoder.yudao.framework.operatelog.core.Logger;

import java.io.*;

/**
 * @auth zh 2021/11/16 14:02
 */
public class SerializableUtil {

    public static void ser(String fileName, Object serObject) throws IOException {
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(fileName));
        objectOutputStream.writeObject(serObject);
        objectOutputStream.close();
    }

    public static Object desSer(String fileName) throws IOException, ClassNotFoundException {
        FileInputStream file = new FileInputStream(fileName);
        ObjectInputStream objectInputStream = null;
        Object object = null;
        if (file.available() > 0) {
            objectInputStream = new ObjectInputStream(file);
            while (file.available() > 0) {
                object = objectInputStream.readObject();
            }
            objectInputStream.close();
            file.close();
        }
        return object;
    }
}
